import logging
import json
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from constants.callback_events import SELECT_SUBJECT_ACTION
from services.fipi import Subject


def create_subjects_keyboard(subjects: list[Subject]) -> InlineKeyboardMarkup:
    keyboard = InlineKeyboardMarkup(row_width=2)

    for subject in subjects:
        callback_data = callback_data = f"{SELECT_SUBJECT_ACTION}:{subject.id}"

        keyboard.add(
            InlineKeyboardButton(
                text=subject.name,
                callback_data=callback_data,
            ))

    return keyboard
